﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OutlookTags.Controls
{
    /// <summary>
    /// Interaction logic for TagsList.xaml
    /// </summary>
    public partial class TagsList : UserControl, ITagsView
    {
        TagsController _controller;

        public TagsList()
        {
            InitializeComponent();
        }

        #region ITagsView Members

        public void Initialize(TagsController controller)
        {
            _controller = controller;
        }

        public void UpdateDisplayTags(IList<DisplayTag> displayTags)
        {
            tagsList.Items.Clear();
            foreach (var tag in displayTags)
            {
                tagsList.Items.Add(tag);
            }

        }

        public void UpdateSelection(IList<DisplayTag> displayTags)
        {

        }

        public void SetArchiveEnabled(bool enabled)
        {

        }

        #endregion

        private void tagsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            
        }

        private void tagsList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (tagsList.SelectedItems.Count > 0)
            {
                string tag = tagsList.SelectedItem.ToString();
                _controller.SearchTag(new string[] { tag });
            }
        }
    }
}
